package com.asiainfo.cms.system.controller.monitor;

import com.asiainfo.cms.common.result.Result;
import com.asiainfo.cms.common.util.ServletUtils;
import com.asiainfo.cms.system.entity.SysLogininfor;
import com.asiainfo.cms.system.service.ISysLogininforService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 系统访问记录
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/monitor/logininfor")
public class SysLogininforController {
    @Autowired
    private ISysLogininforService logininforService;

    @PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
    @GetMapping("/list")
    public Result list(SysLogininfor logininfor) {
        int pageNum = ServletUtils.getParameterToInt("pageNum");
        int pageSize = ServletUtils.getParameterToInt("pageSize");
        Page<SysLogininfor> page = new Page<>(pageNum, pageSize);
        return Result.success(logininforService.selectLogininforList(page, logininfor));
    }

//    @PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, SysLogininfor logininfor) {
//        List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
//        ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
//        util.exportExcel(response, list, "登录日志");
//    }

    @PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
    @DeleteMapping("/{infoIds}")
    public Result remove(@PathVariable Long[] infoIds) {
        return Result.success(logininforService.deleteLogininforByIds(infoIds));
    }

}
